<template>
    <div>
      <el-dialog
        title="发布问题"
        :visible.sync="dialogVisible"
        width="45%"
        center
        :before-close="closePublish">
<!--        <div>-->
<!--          <el-input v-model="problemInfo." placeholder="请输入作业题目"></el-input>-->
<!--        </div>-->
        <tinymce v-model="problemInfo.problemContent" :value="problemInfo.problemContent"></tinymce>
        <span slot="footer" class="dialog-footer">
          <el-button @click="closePublish">取 消</el-button>
          <el-button type="primary" @click="handlePublish">发 布</el-button>
        </span>
      </el-dialog>
    </div>
</template>
<script>

  import {getInfo} from '@/api/user'
  import {postProblem} from '@/api/problems'
  export default {
    components: {},
    props:{
      showPublish: false
    },
    data() {
      return {
        problemInfo:{
          qid:'',
          problemContent:'',
          fid:'',
          sid:'',
          url:''
        },
        dialogVisible: false
      }
    },
    methods: {
      closePublish(){
        this.$emit('noShow')
      },
      handlePublish(){
        postProblem({...this.problemInfo}).then(res => {
          this.$message.success('发布成功！')
          this.$emit('noShow')
        }).catch(err => {
          this.$message.error('请求失败！')
        })
      }
    },
    watch:{
      showPublish:{
        handler(val){
          this.dialogVisible = val
        },
        immediate:true
      }
    }
  }
</script>
<style scoped></style>
